package com.moleq.adapter;

import java.util.List;

import com.moleq.mgpos.activities.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ReportAdapter extends BaseAdapter {
	private LayoutInflater mInflater;
	private List<String> Source;
	private Context context;
	private int selectedRow = 0;
	private ViewHolder holder = null;
	
	public ReportAdapter(Context context,List<String> Source){
		this.context = context;
		this.mInflater = LayoutInflater.from(context);
		this.Source = Source;
	}
	
	public void setSource(List<String> Source){
		this.Source = Source;
	}
	
	public int getCount() {
		return Source.size();
	}

	public Object getItem(int position) {
		return Source.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.report_list_item, null);
			holder.tv_report_item = (TextView) convertView.findViewById(R.id.tv_report_item);
			convertView.setTag(holder);
		}else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.tv_report_item.setText(String.valueOf(Source.get(position)));
		return convertView;
	}
	public final class ViewHolder{
		public TextView tv_report_item;
	}
	public void ScrollToRow(int row) {
		selectedRow = row;
		this.notifyDataSetChanged();
	}
	public int GetSelectedIndex(){
		return selectedRow;
	}
}
